package com.e3.basdoc.dept.model;

import java.util.Date;

import com.e3.basdoc.region.model.RegionModel;
import com.e3.template.model.TGFTreeModel;

public class DeptModel extends TGFTreeModel implements DeptFields {

	private static final long serialVersionUID = -9089756375817175015L;

	private RegionModel region;

	private Long regionId;

	public String getCode() {
		return get(DeptFields.CODE);
	}

	public void setCode(String code) {
		set(DeptFields.CODE, code);
	}

	public String getName() {
		return get(DeptFields.NAME);
	}

	public void setName(String name) {
		set(DeptFields.NAME, name);
	}

	public String getShortName() {
		return get(DeptFields.SHORT_NAME);
	}

	public void setShortName(String shortName) {
		set(DeptFields.SHORT_NAME, shortName);
	}

	public String getType() {
		return get(DeptFields.TYPE);
	}

	public void setType(String type) {
		set(DeptFields.TYPE, type);
	}

	public String getOfficeAddress() {
		return get(DeptFields.OFFICE_ADDRESS);
	}

	public void setOfficeAddress(String officeAddress) {
		set(DeptFields.OFFICE_ADDRESS, officeAddress);
	}

	public Long getRegionId() {
		if(regionId == null){
			return getRefModelId(DeptModel.REGION);
		}
		return this.regionId;
	}

	public void setRegionId(Long regionId) {
		this.regionId = regionId;
	}

	public RegionModel getRegion() {
		return get(DeptFields.REGION);
	}

	public void setRegion(RegionModel region) {
		set(DeptFields.REGION, region);
		if(region!=null){
			setRegionId(region.getId());
		}
		else{
			setRegionId(0L);
		}
	}

	public String getContactAddr() {
		return get(DeptFields.CONTACT_ADDRESS);
	}

	public void setContactAddr(String contactAddr) {
		set(DeptFields.CONTACT_ADDRESS, contactAddr);
	}

	public String getFax() {
		return get(DeptFields.FAX);
	}

	public void setFax(String fax) {
		set(DeptFields.FAX, fax);
	}

	public String getZipcode() {
		return get(DeptFields.ZIPCODE);
	}

	public void setZipcode(String zipcode) {
		set(DeptFields.ZIPCODE, zipcode);
	}

	public String getTelphone() {
		return get(DeptFields.TELPHONE);
	}

	public void setTelphone(String telphone) {
		set(DeptFields.TELPHONE, telphone);
	}

	public String getEmail() {
		return get(DeptFields.EMAIL);
	}

	public void setEmail(String email) {
		set(DeptFields.EMAIL, email);
	}

	public String getManager() {
		return get(DeptFields.MANAGER);
	}

	public void setManager(String manager) {
		set(DeptFields.MANAGER, manager);
	}

	public String getContactPerson() {
		return get(DeptFields.CONTACT_PERSON);
	}

	public void setContactPerson(String contactPerson) {
		set(DeptFields.CONTACT_PERSON, contactPerson);
	}

	public String getContactWay() {
		return get(DeptFields.CONTACT_WAY);
	}

	public void setContactWay(String contactWay) {
		set(DeptFields.CONTACT_WAY, contactWay);
	}

	public Date getFoundTime() {
		return get(DeptFields.FOUND_TIME);
	}

	public void setFoundTime(Date foundTime) {
		set(DeptFields.FOUND_TIME, foundTime);
	}

	public DeptModel getParentDept() {
		return get(DeptFields.PARENT_DEPT);
	}

	public void setParentDept(DeptModel parentDept) {
		set(DeptFields.PARENT_DEPT, parentDept);
		if(parentDept!=null){
			setParentId(parentDept.getId());
		}
		else{
			setParentId(0L);
		}
	}

	public String getRemark() {
		return get(DeptFields.REMARK);
	}

	public void setRemark(String remark) {
		set(DeptFields.REMARK, remark);
	}

	public Long getCorpId() {
		return getLongValue(DeptFields.CORPID);
	}

	public void setCorpId(String corpId) {
		set(DeptFields.CORPID, corpId);
	}

	public void setStatus(String status) {
		set(DeptFields.STATUS, status);
	}

	public String getStatus() {
		return get(DeptFields.STATUS);
	}

	public String toString() {
		return getName();
	}

	public String[] getModelFields() {
		return DeptFields.fieldNames;
	}

	@Override
	public String getParentFiledName() {
		return DeptFields.PARENT_DEPT;
	}

}
